<?php
/**
 * Created by PhpStorm.
 * User: 毛文科
 * Date: 2018\10\28 0028
 * Time: 10:03
 */
namespace app\admin\controller;
use think\Db;
use think\Request;

class Userjur
{
    /**加载列表
     * @param Request $request
     * @return \think\response\View
     */
    public function show_list(Request $request){
        $tiaojian = $request->param('tiaojian',null);
        if($tiaojian){
            $data = Db::name('userjur')->where('jur_name','like',"%$tiaojian%")->order('id desc')->select();
            $datarows = count($data);
        }else{
            $data = Db::name('userjur')->order('id desc')->select();
            $datarows = count($data);
        }
        return view('list',['data'=>$data,'tiaojian'=>$tiaojian,'datarows'=>$datarows]);
    }

    /**加载添加页面
     * @param Request $request
     * @return \think\response\View
     */
    public function show_add(Request $request){
        return view('add');
    }

    /**添加权限
     * @param Request $request
     * @return int|string
     */
    public function add(Request $request){
        $data = $request->param();
        if(!$data['jur_name']){
            return '请输入权限名称';
        }
        if(Db::name('userjur')->insert($data)){
            return 1;
        }else{
            return '添加失败';
        }
    }
    public function edit(Request $request){
        $id = $request->param('id',null);
        if(!$id){
            return '请输入要修改的id';
        }
        $data = Db::name('userjur')->where('id',$id)->find();
    }
}